<?php
# vim: syntax=php tabstop=4 softtabstop=0 noexpandtab laststatus=1 ruler

/**
 *
 * @author yangfeng <81177622@qq.com>
 * @copyright 2018-2020 yangfeng
 * @version 20180506
 */
//echo exec('whoami');
//echo shell_exec("id -a");
if($_GET["action"]=="fix")
	{
		$o = "" ;
		$cmd = 'sudo /usr/yangfeng/fixpermissions.sh 2>&1';
		exec($cmd, $o, $rc);
		if ($rc == 0) {
			$msg = '266';
		} else {
			$msg = '267';
		};
	}
	elseif($_GET["action"]=="dl")
	{
		$o = "" ;
		$cmd = 'grep -i -o "\$node_templates\[\$templ\] = \$desc.TEMPLATE_DISABLED  ;" /opt/unetlab/html/includes/init.php 2>&1';
		exec($cmd, $o, $rc);
		if ($rc == 0) {
			$cmd = 'sudo /usr/yangfeng/showdevice.sh 2>&1';
			exec($cmd, $o, $rc);
			$msg = '268';
		} else {
			$cmd = 'grep -i -o "\$node_templates\[\$templ\] = \$desc...missing.;" /opt/unetlab/html/includes/init.php 2>&1';
			exec($cmd, $o, $rc);
			if ($rc == 0) {
				$cmd = 'sudo /usr/yangfeng/showdevice.sh 2>&1';
				exec($cmd, $o, $rc);
				$msg = '268';
			}else{
				$cmd = 'sudo /usr/yangfeng/hidedevice.sh 2>&1';
				exec($cmd, $o, $rc);
				$msg = '269';
			}
		};	 	
	}
	elseif($_GET["action"]=="iou")
	{
		$o = "" ;
		$cmd = 'sudo /usr/yangfeng/IOUKeygen.sh 2>&1';
		exec($cmd, $o, $rc);
		if ($rc == 0) {
			$msg = '270';
		} else {
			$msg = '271';
		};	 	
	}
	elseif($_GET["action"]=="cn")
	{
		// $o = "" ;
		// $cmd = 'sudo /usr/yangfeng/language_zh.sh 2>&1';
		// exec($cmd, $o, $rc);
		// if ($rc == 0) {
			// $msg = '272';
		// } else {
			// $msg = '273';
		// };
	}
	elseif($_GET["action"]=="en")
	{
		// $o = "" ;
		// $cmd = 'sudo /usr/yangfeng/language_en.sh 2>&1';
		// exec($cmd, $o, $rc);
		// if ($rc == 0) {
			// $msg = '274';
		// } else {
			// $msg = '275';
		// };
	}
	
?>
<?php echo $msg;?>